$(document).ready(function(){
	active();
	initQuestionReading();
});
function getQuestionByAccept(size,index,isAccept){
	var url = "/HyperIT/question/getQuestionByAccept";
	var parm = "size="+size+"&indexPageNum="+index+"&is_accept="+isAccept;
	$.get(url,parm,function(data){
		if (data.serviceResult) {
			var list = data.resultParm.question_user;
			 showQuestion(list);
		} else{
			messageTip(data.resultInfo);
		}
	});
}
function getQuestionByAnswer(size,index){
	var url = "/HyperIT/question/getQuestionByAnswer";
	var parm = "size="+size+"&indexPageNum="+index;
	$.get(url,parm,function(data){
		if (data.serviceResult) {
			var list = data.resultParm.question_user;
			 showQuestion(list);
		} else{
			messageTip(data.resultInfo);
		}
	});
}
function getQuestionByTime(size,index){
	var url = "/HyperIT/question/getQuestion";
	var parm = "size="+size+"&indexPageNum="+index;
	$.get(url,parm,function(data){
		if (data.serviceResult) {
			var list = data.resultParm.question_user;
			 showQuestion(list);
		} else{
			messageTip(data.resultInfo);
		}
	});
}
function getQuestionBySearch(size,index){
	if($("#articleSearch").val().trim()==""){
		messageTip("请输入标签的关键字");
	}else{
		$(".aq-items .aq-item").remove();
		var url = "/HyperIT/question/SearchQuestion";
		var parm = "size="+size+"&indexPageNum="+index+"&search="+$("#articleSearch").val();
		$.get(url,parm,function(data){
			if (data.serviceResult) {
				var list = data.resultParm.question_user;
				 showQuestion(list);
			} else{
				messageTip(data.resultInfo);
			}
		});
	}
}
function active(){
	$("#ranking ul").children("li").click(function(){
		$(this).addClass("active").siblings().removeClass("active");
		selectCard($(this).index());
	});
}
function selectCard(index){
	switch (index){
		case 0:
			initQuestionReading();
			break;
		case 1:
			initQuestionAnswer();
			break;
		case 2:
			initQuestionAccepted();
			break;
		case 3:
			initQuestionAcceptless();
			break;
		case 4:
			initQuestionTime();
			break;
		default:
			break;
	}
}
function initQuestionReading(){
	$(".aq-items .aq-item").remove();
	getQuestionByReading(100000,1);
}
function initQuestionAnswer(){
	$(".aq-items .aq-item").remove();
	getQuestionByAnswer(1000000,1);
}
function initQuestionAccepted(){
	$(".aq-items .aq-item").remove();
	getQuestionByAccept(100000,1,1);
}
function initQuestionAcceptless(){
	$(".aq-items .aq-item").remove();
	getQuestionByAccept(100000,1,0);
}
function initQuestionTime(){
	$(".aq-items .aq-item").remove();
	getQuestionByTime(1000000,1);
}
